import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/safe_entity.dart';

SafeEntity $SafeEntityFromJson(Map<String, dynamic> json) {
  final SafeEntity safeEntity = SafeEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    safeEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    safeEntity.msg = msg;
  }
  final List<SafeData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<SafeData>(e) as SafeData).toList();
  if (data != null) {
    safeEntity.data = data;
  }
  return safeEntity;
}

Map<String, dynamic> $SafeEntityToJson(SafeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension SafeEntityExtension on SafeEntity {
  SafeEntity copyWith({
    int? code,
    String? msg,
    List<SafeData>? data,
  }) {
    return SafeEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

SafeData $SafeDataFromJson(Map<String, dynamic> json) {
  final SafeData safeData = SafeData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    safeData.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    safeData.title = title;
  }
  final String? imgUrl = jsonConvert.convert<String>(json['img_url']);
  if (imgUrl != null) {
    safeData.imgUrl = imgUrl;
  }
  return safeData;
}

Map<String, dynamic> $SafeDataToJson(SafeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['img_url'] = entity.imgUrl;
  return data;
}

extension SafeDataExtension on SafeData {
  SafeData copyWith({
    int? id,
    String? title,
    String? imgUrl,
  }) {
    return SafeData()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..imgUrl = imgUrl ?? this.imgUrl;
  }
}